/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bean;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

/**
 *
 * @author Sunder
 */
@ManagedBean
@RequestScoped
@SessionScoped
public class BeanCabecalho {
    private String nomeUsuario;
    private int idPermissao;
    /**
     * Creates a new instance of BeanCabecalho
     */
    public BeanCabecalho() {
        FacesContext context = FacesContext.getCurrentInstance();  
        HttpSession session = (HttpSession) context.getExternalContext().getSession(false);  
        nomeUsuario = (String) session.getAttribute("nomeUsuario");
        idPermissao = Integer.parseInt(session.getAttribute("permissao").toString());
    }
    
    public String encerrar(){
        FacesContext context = FacesContext.getCurrentInstance();  
        HttpSession session = (HttpSession) context.getExternalContext().getSession(false); 
        session.invalidate();
        System.out.println("WWWWWWWWWWWWWWWWWWWWW");
        return "index";
    }
    
    public String getNomeUsuario() {
        return nomeUsuario;
    }

    public void setNomeUsuario(String nomeUsuario) {
        this.nomeUsuario = nomeUsuario;
    }

    public int getIdPermissao() {
        return idPermissao;
    }

    public void setIdPermissao(int idPermissao) {
        this.idPermissao = idPermissao;
    }
}
